<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<title>福利物品添加页面</title>
<link href="<%=request.getContextPath()%>/css/Default.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/redmond/jquery-ui-1.8.14.custom.css"
	rel="stylesheet" type="text/css"></link>
<link href="<%=request.getContextPath()%>/css/Dialog.css"
	rel="stylesheet" type="text/css"></link>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="<%=request.getContextPath()%>/scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/scripts/HRM.js" type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/scripts/jquery-ui-1.8.14.min.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/scripts/jquery.validate.min.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/scripts/jquery.validate.message_cn.js"
	type="text/javascript"></script>
<script
	src="<%=request.getContextPath()%>/scripts/Dialog.js"
	type="text/javascript"></script>
</head>
<body class="dialogBody">
<script type="text/javascript">
function beforeFormSubmitFunc(){
	var url=$("#rewardAddForm").attr('action');
	$("#rewardAddForm").attr('action',url);
	if(!$("#rewardAddForm").valid()){
		createAlertDialog('提示信息','还有未正确填写的项，请参照提示修改!');
		return false;
	}else{
		return true;
	}
}
$().ready(function(){
	$("#rewardAddForm").validate({
		rules:{
			rewardName:{
				required:true,
				maxlength:50
			},
			rewardPrice:{
				required:true,
				doubleValid:true
			},
			rewardAmount:{
				required:true,
				digits:true
			},
			rewardTotal:{
				required:true,
				doubleValid:true
			},
			remark:{
				maxlength:200
			}
		},
		errorPlacement:function(error,element){
			createTooltip(error,element);
		},
		success:function(error,element){
			sucRemoveTooltip(error);
		},
		event:'blur'|'keyup'|'focus'|'keydown'|'change'
	});
	$('#rewardAddForm').find("input").focus(function(){
		$(this).valid();
	});
	$('#rewardAddForm').find("input").blur(function(){
		$('#'+$(this).attr('id')+'Error').remove();
	});
	$('#rewardAddForm').find('#name').focus();
	getConfigItemsToSelect("RewardType",$("#rewardType"),"请输入新的福利物品类型");
	getConfigItemsToSelect("RewardPurpose",$("#rewardPurpose"),"请输入新的福利物品用途");
	getConfigItemsToSelect("RewardUnit",$("#rewardUnit"),"请输入新的福利物品单位");
	
	$("#rewardPrice").unbind('blur').bind('blur',function(){
		if($("#rewardAmount").val()!=''){
			var total=Number($(this).val())*Number($("#rewardAmount").val());
			$("#rewardTotal").val(total);
		}
	});
	$("#rewardAmount").unbind('blur').bind('blur',function(){
		var total=Number($(this).val())*Number($("#rewardPrice").val());
		$("#rewardTotal").val(total);
	});
// 	$("#rewardTotal").unbind('focus').bind('focus',function(){
// 		var total=Number($(this).val())*Number($("#rewardPrice").val());
// 		$("#rewardTotal").val(total);
// 	});
	
});
function getConfigItemsToSelect(type,selectObj,msg){
	var path='<%=request.getContextPath()%>/config.do?method=getConfigItemsByConfigType&type='+type;
	$.getJSON(path,function(data,status,xhr){
		selectObj.html("");
		data=data[0];
		var optionHtml="";
		for(var i=0;i<data.length;i++){
			optionHtml+="<option value='"+data[i]['configType']+"."+data[i]['configCode']+"'>"+data[i]['configName']+"</option>";
		}
		optionHtml += "<option value='-1'>其它</option>";
		selectObj.html(optionHtml);
		selectObj.unbind('change').bind('change',function(){
			if($(this).val()=='-1'){
				createPromptDialog(msg,type,$(this));
			}
		});
	});
}
</script>
<form id="rewardAddForm" action='<%=request.getContextPath()%>/reward.do?method=addReward' method="post">
<table width="430" height="227" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <td height="10"></td>
      <td></td>
    </tr>
    <tr>
      <td>
   <fieldset>
    <legend><label>基本信息</label></legend>
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="39%" height="30" align="right" >福利物品名称：</td>
          <td width="61%"><input name="rewardName"  type="text" value="" id="rewardName" /><span class='requiredSpan'>*</span></td>
        </tr>
        <tr>
          <td height="30" align="right" >福利物品类型：</td>
          <td><select id='rewardType' name='rewardType'></select><span class='requiredSpan'>*</span></td>
        </tr>
        <tr>
          <td height="30" align="right" >福利物品数量：</td>
          <td><input name="rewardAmount" type="text" id="rewardAmount"/><span class='requiredSpan'>*</span></td>
        </tr>
        <tr>
          <td height="30" align="right" >福利物品单价：</td>
          <td><input name="rewardPrice" type="text" id="rewardPrice"/><span class='requiredSpan'>*</span></td>
        </tr>
        <tr>
          <td height="30" align="right" >福利物品单位：</td>
          <td><select id='rewardUnit' name='rewardUnit'></select><span class='requiredSpan'>*</span></td>
        </tr>
        <tr>
          <td height="30" align="right" >福利物品总计：</td>
          <td><input name="rewardTotal" type="text" id="rewardTotal"/><span class='requiredSpan'>*</span></td>
        </tr>
        <tr>
          <td height="30" align="right" >福利物品用途：</td>
          <td><select id='rewardPurpose' name='rewardPurpose'></select><span class='requiredSpan'>*</span></td>
        </tr>
        <tr>
          <td height="30" align="right" >备注：</td>
          <td><textarea style="width: 118px; height: 60px;" name="remark" id="remark"></textarea></td>
        </tr>
      </table></fieldset></td>
    </tr>
	</table>
</form>

</body>
</html>